package ita.class1.group2.supermarket.customer.service;

import ita.class1.group2.supermarket.common.annotation.Autowired;
import ita.class1.group2.supermarket.common.annotation.Component;
import ita.class1.group2.supermarket.common.pojo.Page;
import ita.class1.group2.supermarket.common.service.BaseService;
import ita.class1.group2.supermarket.customer.dao.StoreInformationDao;
import ita.class1.group2.supermarket.customer.dto.StoreDetailInfomation;
import ita.class1.group2.supermarket.customer.handler.DataHandler;
import ita.class1.group2.supermarket.customer.pojo.Store;
import ita.class1.group2.supermarket.customer.pojo.StoreInformation;

import java.util.List;
import java.util.Map;
@Component
public class StoreInformationService implements BaseService<StoreInformation, String> {

    @Autowired
    private StoreInformationDao storeInformationDao;

    @Override
    public StoreInformation find(String s) {
        return storeInformationDao.find(s);
    }

    @Override
    public List<StoreInformation> findAll() {
        return null;
    }

    @Override
    public StoreInformation save(StoreInformation storeInformation) {
        return null;
    }

    @Override
    public boolean delete(String s) {
        return false;
    }

    @Override
    public List<StoreInformation> findByCondition(Map map) {
        return null;
    }

    @Override
    public boolean update(StoreInformation storeInformation) {
        return false;
    }

    public Page<StoreDetailInfomation> findStoreInformationsBySids(List<String> sids, Integer pageIndex, Integer pageCount,List<Store> stores) {
        int total = storeInformationDao.findStoreInformationsCountBySids(sids);
        List<StoreInformation> storeInformations = storeInformationDao.findStoreInformationsBySids(sids, pageIndex, pageCount);
        List<StoreDetailInfomation> storeDetailInfomations = DataHandler.packingData(stores,storeInformations);
        System.out.println("service size:"+storeDetailInfomations.size());
        Page<StoreDetailInfomation> page = new Page<>(pageIndex,pageCount,storeDetailInfomations,total);
        return page;
    }

    public StoreInformation findStoreInformation(String sId) {
        return storeInformationDao.findStoreInformation(sId);
    }
}
